<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script language="javascript">
    function saveform() {
        if ($("#sku").val() == "") {
            $("#skuerr").html('商品编号(SKU)不能为空！');
            return false;
        }
        if ($("#name").val() == "") {
            $("#nameerr").html('不能为空！');
            return false;
        }

        if ($("#supplier").val() == "") {
            $("#suppliererr").html('来源必须选择！');
            return false;
        }
        if ($("#saleprice").val() == "") {
            $("#salepriceerrerr").html('预售价不能为空！');
            return false;
        }
        AWS.ajax_post($('#otherForm'));
        //$("#otherForm").submit();

    }
    function getSku() {
        var sku = $("#sku").val();
        if (sku) {
            $("#skuerr").html('<img src="/fuman/images/loaders/loader2.gif">');
            $.post("/product/ajaxbutton", {"op": "searchsku","sku":sku}, function (data) {
                if (data == 200) {
                    getdevelop(sku);
                    $("#skuerr").html('');
                } else {
                    $("#skuerr").html('<font color=red>SKU[' + sku + ']已经存在！</font>');
                    //$("#sku").val('');
                }
            }, "json");
        }
    }
    function getdevelop(sku) {
        if (sku) {
            $("#skuerr").html('<img src="/fuman/images/loaders/loader2.gif">');
            $.post("/product/ajaxbutton", {"op": "searchdevelopsku","sku":sku}, function (data) {
                if (data == 200) {
                    $("#skuerr").html('');
                } else {
                    $("#skuerr").html('<font color=red>SKU[' + sku + ']已经存在！</font>');
                    $("#sku").val('');
                }
            }, "json");
        }
    }
    function changsupplier() {
        var supplier = $("#supplier").val();
        if (supplier == 3) {
            $("#showsupplier").show();
        } else {
            $("#showsupplier").hide();
        }
    }

</script>
<title>添加开发新品</title>
<body class="withvernav">
<div class="bodywrapper">
    {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">

        <div class="pageheader notab">
            <h1 class="pagetitle">添加开发新品</h1>
            <span class="pagedesc"></span>
            <div class="menulist">
                <ul class="profile_summary">
                    <li class="current"><a href="/product/newproduct">新品开发列表</a></li>

                </ul>
            </div>
        </div><!--pageheader-->

        <div id="contentwrapper" class="contentwrapper">

            <div id="basicform" class="subcontent">
                <form class="stdform stdform2" id="otherForm" method="post" enctype='multipart/form-data'
                      action="/product/ajaxbutton?op=savenewproduct">

                    <p>
                        <label>商品编号 *</label>
                            <span class="field">
                          <input type="text" name="sku" id="sku" class="width100" value="{{$detail.sku}}"
                                 onKeyUp="this.value=this.value.replace(/[^\w_\w-]/g,'');" {{if $detail.id}}
                                 readonly {{else}} onBlur="getSku()"{{/if}} required>
                          <span id="skuerr"></span>
                    </p>
                    <p>
                        <label>中文名称 *</label>
                            <span class="field">
                          {{if $arr_externalbuy}}
                                <input type="text" name="name" id="name" class="width400" value="{{$arr_externalbuy.p_parent_name}}" required>
                           {{else}}
                          <input type="text" name="name" id="name" class="width400" value="{{$detail.name}}" required>
                           {{/if}}
                          <span id="nameerr"></span>
                    </p>
                    <p>
                        <label>英文名称</label>
                            <span class="field">
                                {{if $arr_externalbuy}}
                                <input type="text" name="en_name" id="en_name" class="width400" value="{{$arr_externalbuy.p_en_goods_name}}" required>
                                {{else}}
                                <input type="text" name="en_name" id="en_name" class="width400" value="{{$detail.en_name}}" required>
                                {{/if}}


                    </p>
                    <p>
                        <label>来源 *</label>
                            <span class="field">
                        <select name="supplier" id="supplier" class="selection" style="width:200px;"
                                onChange="changsupplier()" required>
                            <option value="">请选择</option>
                            <option value="1" {{if $detail.supplier==1}} selected{{/if}}>工厂1</option>
                            <option value="2" {{if $detail.supplier==2}} selected{{/if}}>工厂2</option>
                            <option value="7" {{if $detail.supplier==7}} selected{{/if}}>广州</option>
                            <!--
                            {{foreach from=$factory item=res key=key}}
                            
                            <option value="{{$res.id}}" {{if $detail.supplier==$res.id}}
                                    selected{{/if}}>{{$res.name}}</option>
                            {{/foreach}}
                            -->
                        </select>
                          <span id="suppliererr"></span>

                    </p>
                         
                        <!-- <span id="showsupplier" style="display:none">
                         <p>
                             <label>供应商</label>
                            <span class="field">
                          <input type="text" name="suppliername" id="suppliername" class="width200"
                                 value="{{$detail.suppliername}}">
                            </span>
                         </p>
                        <p>
                            <label>联系方式</label>
                            <span class="field">
                          <input type="text" name="contect" id="contect" class="width200" value="{{$detail.contect}}">
                            </span>
                        </p>
                        <p>
                            <label>网址</label>
                            <span class="field">
                          <input type="text" name="weburl" id="weburl" class="width400" value="{{$detail.weburl}}">
                            </span>
                        </p>
                        </span>-->

					<p>
                        <label>性别*</label>
                            <span class="field">
                          
                           <input name="gender" type="radio" value="1" {{if $detail.gender==1}} checked{{/if}}> 男 &nbsp;&nbsp;
                             <input name="gender" type="radio" value="2" {{if $detail.gender==2}} checked{{/if}}> 女
                               <input name="gender" type="radio" value="3" {{if $detail.gender==3}} checked{{/if}}> 通用
                               <input name="gender" type="radio" value="4" {{if $detail.gender==4}} checked{{/if}}> 广码
                           
                            </span>
                    </p>
                    <p>
                        <label>预售价*</label>
                            <span class="field">
                                {{if $arr_externalbuy}}
                                <input type="text" name="saleprice" id="saleprice" class="width100" value="{{$arr_externalbuy.p_sellprice}}">
                                {{else}}
                                <input type="text" name="saleprice" id="saleprice" class="width100" value="{{$detail.saleprice}}">
                                {{/if}}

                            <span id="salepriceerrerr"></span>
                            </span>
                    </p>


                    <p>
                        <label>期望完成时间</label>
                            <span class="field">
                       <input type="text" name="tbopertime" value="{{$detail.tbopertime}} "
                              onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker"/>
                            </span>
                    </p>
                    <p>
                        <label>备注</label>
                            <span class="field">
                                {{if $arr_externalbuy}}
                                <textarea name="memo" cols="8" rows="8">{{$arr_externalbuy.memo}}</textarea>
                                {{else}}
                                <textarea name="memo" cols="8" rows="8">{{$detail.memo}}</textarea>
                                {{/if}}

                            </span>
                    </p>

                    <p class="stdformbutton">
                            <input type="hidden" value="{{$sku}}" name="externalSku" id="externalSku"/>
                        	<span><button type="button" class="submit radius2" id="btn" onClick="saveform()">保存</button>
                            <input type="hidden" name="id" value="{{$detail.id}}" id="id">
                    </p>
                </form>

                <br/>

            </div><!--subcontent-->

            <!--subcontent-->

        </div><!--contentwrapper-->

    </div><!-- centercontent -->


</div><!--bodywrapper-->

</body>
</html>
